package com.jinke.api.modules.app.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.jinke.api.common.api.CommonPage;
import com.jinke.api.common.api.CommonResult;
import com.jinke.api.modules.app.controller.param.CompanySellerProfitParam;
import com.jinke.api.modules.app.model.Order;
import com.jinke.api.modules.app.model.OrderParcel;
import com.jinke.api.modules.app.request.*;
import com.jinke.api.modules.app.response.*;
import com.jinke.api.modules.third.ezeeship.model.request.EstimateRateRequest;
import com.jinke.api.modules.ums.dto.*;
import com.jinke.api.modules.ums.model.Channel;
import com.jinke.api.modules.ums.model.DailyOrderAmountGroupbySellerVO;
import com.jinke.api.modules.ums.model.DailyOrderAmountVO;
import com.jinke.api.modules.ums.model.UmsAdmin;
import com.jinke.api.modules.ums.request.UNRefundedOrderPageRequest;
import com.jinke.api.modules.ums.vo.UNRefundedOrderPageVO;
import org.springframework.web.multipart.MultipartFile;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * <p>
 * 承运商平台 服务类
 * </p>
 *
 * @author macro
 * @since 2024-01-15
 */
public interface OrderService extends IService<Order> {

    List<GetOrdersResponse> buildOrders(List<ExcelOrder> list);

    /**
     * 查询运单
     * @param request
     * @return
     */
    CommonPage<GetOrdersResponse> getGetOrdersResponseCommonPage(OrderExportsRequest request);

    /**
     * 重构查询运单 下载重构了
     * @param request
     * @return
     */
    CommonPage<GetOrdersResponse> getGetOrdersResponseCommonPageyouhua(OrderExportsRequest request);

    Integer handleOrders(String response);

    //CommonResult<String> batchCreate(BatchCreateLabelOrderRequest request);
    //老费率估算 有提示，展示到渠道级别
    CommonResult<EstimateRateOrderResponse> estimateRate(EstimateRateRequest request);
    //新预估没提示只展示服务层最终结果
    CommonResult<EstimateRateOrderResponse> estimateRateNew(EstimateRateRequest request);
    //批量费率估算
    CommonResult<List<BatchEstimateRateResponse>> batchEstimateRate(BatchEstimateRateRequest request);
    //新批量
    CommonResult<List<BatchEstimateRateResponse>> batchEstimateRateNew(BatchEstimateRateRequest request);

    CommonResult<String> downLabel(OrderCancelRequest request);

    CommonResult<String> download(OrderExportsRequest request);

    CommonResult<String> downLabel2(OrderExportsRequest request);

    CommonResult<String> releaseEarnest(OrderReleaseEarnestRequest request);

    CommonResult<String> copy(OrderCopyRequest request);

    CommonResult<List<EstimateRateRequest>> uploadOrder(MultipartFile file);

    long checkOrderNo(EstimateRateRequest request);

    /**
     * 不可重复
     * @param request
     */
    Integer checkOrderNoNoRepeat(EstimateRateRequest request);

    CommonResult<GetOrdersResponse> detail(OrderDetailRequest request);

    CommonResult<EstimateRateOrderResponse> draft(EstimateRateRequest request);

    CommonResult<String> createLabel(EstimateRateRequest estimateRateRequest);

    /**
     * 按组版本-批量下单
     * @param request
     * @param userId
     * @return
     */
    CommonResult<String> batch(List<BatchCreateLabelOrderRequest> request,Integer userId);

    /**
     * 老版本-批量下单
     * @param request
     * @return
     */
    CommonResult<String> batchOld(BatchCreateLabelOrderRequest request);


    EstimateRateRequest getEstimateRateRequest(Integer orderId);

    void fillParcel(Integer orderId, Channel channel, EstimateRateRequest estimateRateRequest);

    /**
     * 保证金批量释放
     *
     * @param request 参数对象
     * @return 是否成功
     */
    CommonResult<String> releaseDeposit(OrderReleaseEarnestRequest request);


    /**
     * 订单取消----审核(通过)
     *
     * @param request 参数
     * @return 结果
     */
    CommonResult<GetOrdersResponse> cancelAudit(OrderCancelAuditRequest request);

    /**
     * 订单取消----审核(拒绝)
     *
     * @param request 参数
     * @return 结果
     */
    CommonResult<GetOrdersResponse> reject(OrderCancelAuditRequest request);

    /**
     * 查询当前用户id，取消订单的订单总额
     *
     * @param id 用户id
     * @return 取消订单金额
     */
    BigDecimal sumRefundAmountByUserId(Integer id);

    /**
     * 订单补扣
     *
     * @param dtos 参数对象
     * @return 是否成功
     */
    CommonResult orderBilled(List<BilledDto> dtos);

    /**
     * 账单补扣
     *
     * @param file 文件
     */
    CommonResult uploadBilled(MultipartFile file);

    /**
     * 获取今日消费前十的用户的消费金额和订单数
     */
    List<UserSumAmountDto> getTopRateByUserDate(List<Integer> orderNormalStatus);

    List<UserSumAmountDto> getAmountNum(Integer userId, List<Integer> orderNormalStatus);

    List<UserSumAmountDto> getUserAmountNum(Integer sellerId, List<Integer> orderNormalStatus);

    public List<DailyOrderAmountVO> getDailyOrderQuantity(CompanySellerProfitParam choseMonth) ;

    List<UserWeekSumAmountDto> getWeekTopRateByUserData(List<Integer> orderNormalStatus);

    List<UserWeekSumAmountDto> getUserWeekAmountNum(Integer sellerId, List<Integer> orderNormalStatus);

    List<UserWeekSumAmountDto> getWeekAmountNum(Integer userId, List<Integer> orderNormalStatus);
    /**
     * 每月各销售名下客户按天金额
     * @return
     */
    List<DailyOrderAmountGroupbySellerVO> dailyAmountGroupBySeller();

    List<UserWeekDaySumAmountDto> getWeekTopRateByUserEveryDay(List<Integer> orderNormalStatus);

    List<UserWeekDaySumAmountDto> getUserWeekDayAmountNum(Integer sellerId, List<Integer> orderNormalStatus);

    List<UserWeekDaySumAmountDto> getWeekDayAmountNum(UmsAdmin userInfo, List<Integer> orderNormalStatus);

    List<UserDayOrderProfitDto> getAllSellerUserDay(List<UmsAdmin> allSellerUsers, List<Integer> orderNormalStatus);

    List<UserMonthStatisticsDto> getSellerPerformanceStatistics(CompanySellerProfitParam choseMonth, List<Integer> orderNormalStatus);

    List<UserMonthStatisticsDto> getSellerPerformanceStatisticsBySId(CompanySellerProfitParam choseMonth, List<Integer> orderNormalStatus);

    List<UserMonthStatisticsDto> getSingleSellerPerformanceStatisticsBySId(CompanySellerProfitParam choseMonth, List<Integer> orderNormalStatus, Integer wzId);

    List<DailyOrderAmountGroupbySellerVO> dailyAmountGroupBySingleSeller(Integer sellerId);


    CommonResult<String> updateByParamType(OrderSupplementaryRequest request);

    void updatePacelstatusByOrderIds(Set<Integer> orderIdsWithInfo, Map<Integer, Order> orderMap);

    void cancelNoByOrderId(Set<Integer> orderIdsWithoutInfo, Map<Integer, Order> orderMap);

    List<UserOrderCountVO> getCountGroupByUserId(Set<Integer> userIds, String startDay, String dayEnd);

    List<UserOrderSummaryVO> countGroupByDate( String startDay, String dayEnd, List<Integer> userId );

      List<OrderParcel> selectUserOrderParcels(String startDay, String dayEnd, List<Integer> userId  ) ;
    //统计发邮箱
    void summaryNoLogister( List<Integer> userId, String startDay, String endDay) ;

    CommonResult<String> auditByTrackingNum(OrderAuditRequest request);

    CommonResult<CommonPage<UNRefundedOrderPageVO>> pageUNRefundedOrder(UNRefundedOrderPageRequest request);

    void mock(List<Integer>    userId, String startDay, String endDay) ;

    void onlyTAcheng( List<Integer>    summaryUserId,    String startDay, String endDay);


    void logistoryRealOrNot(List<OrderParcel> userId);
}
